package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.vo.BaseVO;
import com.jwsoft.manager.common.vo.personInformationAuth.*;
import com.jwsoft.manager.core.integration.PersonInformationAuthIntegration;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

import java.util.List;

/**
 * 个人信息授权网关
 *
 * @author chenzh
 * @since 2024-03-16
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "个人信息授权", description = "个人信息授权")
public class PersonInformationAuthController {

    @Autowired
    public PersonInformationAuthIntegration personInformationAuthIntegration;

    @Operation(summary = "个人信息授权分页查询",description = "个人信息授权分页查询")
    @PostMapping(value = "/personInformationAuth0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<PersonInformationAuthVO>> getList(@RequestBody @Validated PersonInformationAuthQueryVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.getList(vo));
    }

    @Operation(summary = "个人信息授权根据主键查询详情",description = "个人信息授权根据主键查询详情")
    @PostMapping(value = "/personInformationAuth0002", produces = "application/json;charset=UTF-8")
    public AppResponse<PersonInformationAuthVO> getById(@RequestBody @Validated PersonInformationAuthKeyVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.getById(vo));
    }
    @Operation(summary = "根据身份证获取个人信息授权情况",description = "根据身份证获取个人信息授权情况")
    @PostMapping(value = "/personInformationAuth0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<PersonInformationAuthVO>> getByIdcard(@RequestBody @Validated PersonInformationAuthQueryVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.getByIdcard(vo));
    }
    @Operation(summary = "校验登录人是否授权",description = "校验登录人是否授权")
    @PostMapping(value = "/personInformationAuth0009", produces = "application/json;charset=UTF-8")
    public AppResponse<Boolean> checkAuth(@RequestBody @Validated PersonInformationAuthCheckVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.checkAuth(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "个人信息授权保存",description = "个人信息授权保存")
    @PostMapping(value = "/personInformationAuth0008", produces = "application/json;charset=UTF-8")
    public AppResponse save(@RequestBody  PersonInformationAuthSaveVO vo) {
        personInformationAuthIntegration.save(vo);
        return AppResponse.success();
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "个人信息授权新增",description = "个人信息授权新增")
    @PostMapping(value = "/personInformationAuth0004", produces = "application/json;charset=UTF-8")
    public AppResponse<PersonInformationAuthVO> add(@RequestBody @Validated(value = {Validators.Add.class}) PersonInformationAuthVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "个人信息授权修改",description = "个人信息授权修改")
    @PostMapping(value = "/personInformationAuth0005", produces = "application/json;charset=UTF-8")
    public AppResponse<PersonInformationAuthVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) PersonInformationAuthVO vo) {
        return AppResponse.successData(personInformationAuthIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "个人信息授权删除",description = "个人信息授权删除")
    @PostMapping(value = "/personInformationAuth0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated PersonInformationAuthKeyVO vo) {
        personInformationAuthIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
